package com.bml.architect.config;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * 基于AbstractRoutingDataSource的多数据源动态切换
 */
public class DynamicRoutingDataSource extends AbstractRoutingDataSource {
    @Override
    protected Object determineCurrentLookupKey() {
        System.out.println("当前数据源 :"+ DynamicDataSourceContextHolder.getDataSourceKey());
        return DynamicDataSourceContextHolder.getDataSourceKey();
    }
}
